package com.kakarote.hrm.service.impl;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.poi.excel.BigExcelWriter;
import cn.hutool.poi.excel.ExcelUtil;
import com.alibaba.fastjson.JSONObject;
import com.kakarote.common.log.entity.OperationLog;
import com.kakarote.common.log.enums.BehaviorEnum;
import com.kakarote.core.common.MultipartFileUtil;
import com.kakarote.core.common.Result;
import com.kakarote.core.common.cache.AdminCacheKey;
import com.kakarote.core.common.cache.HrmCacheKey;
import com.kakarote.core.common.enums.FieldEnum;
import com.kakarote.core.common.enums.SystemCodeEnum;
import com.kakarote.core.entity.BasePage;
import com.kakarote.core.entity.UploadEntity;
import com.kakarote.core.exception.CrmException;
import com.kakarote.core.feign.admin.service.AdminFileService;
import com.kakarote.core.redis.Redis;
import com.kakarote.core.servlet.BaseServiceImpl;
import com.kakarote.core.utils.ExcelParseUtil;
import com.kakarote.hrm.constant.RecruitPlanReportStatusEnum;
import com.kakarote.hrm.constant.RecruitPlanStatusEnum;
import com.kakarote.hrm.constant.RecruitReportLogConstant;
import com.kakarote.hrm.entity.BO.QueryRecruitPlanPageListBO;
import com.kakarote.hrm.entity.BO.SyncDataInformationBO;
import com.kakarote.hrm.entity.BO.SyncPlanCallbackBO;
import com.kakarote.hrm.entity.BO.UpdateRecruitPlanStatusBO;
import com.kakarote.hrm.entity.PO.HrmRecruitPlan;
import com.kakarote.hrm.entity.PO.HrmRecruitReportLog;
import com.kakarote.hrm.entity.VO.RecruitPlanVO;
import com.kakarote.hrm.entity.VO.RecruitPlanExportVO;
import com.kakarote.hrm.mapper.HrmRecruitPlanMapper;
import com.kakarote.hrm.service.IHrmRecruitPlanService;
import com.kakarote.hrm.service.IHrmRecruitReportLogService;
import dataEncoder.DataEncoderFactory;
import dataEncoder.DataForEncoder;
import org.apache.poi.ss.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.File;
import java.io.InputStream;
import java.time.LocalDateTime;
import java.util.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;

import com.alibaba.excel.EasyExcel;
import cn.hutool.core.bean.BeanUtil;
import org.springframework.web.multipart.MultipartFile;

import static com.kakarote.core.common.enums.SystemCodeEnum.SYSTEM_ERROR;

/**
 * <p>
 * 招聘计划表 服务实现类
 * </p>
 *
 * @author system
 * @since 2024-01-01
 */
@Service
public class HrmRecruitPlanServiceImpl extends BaseServiceImpl<HrmRecruitPlanMapper, HrmRecruitPlan> implements IHrmRecruitPlanService {

    @Autowired
    private HrmRecruitPlanMapper recruitPlanMapper;

    @Autowired
    private Redis redis;

    @Resource
    private AdminFileService adminFileService;

    @Autowired
    private IHrmRecruitReportLogService reportLogService;


    @Value("${sync.algorithm}")
    private String algorithm;
    @Value("${sync.secretKey}")
    private String secretKey;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public OperationLog addRecruitPlan(HrmRecruitPlan recruitPlan) {
        // 生成计划编号
        if (StrUtil.isEmpty(recruitPlan.getPlanCode())) {
            recruitPlan.setPlanCode(generatePlanCode(recruitPlan.getPositionYear()));
        }
        // 设置默认状态为待上报
        if (recruitPlan.getStatus() == null) {
            recruitPlan.setStatus(RecruitPlanStatusEnum.PENDING_REPORT.getStatus());
        }
        boolean save = save(recruitPlan);
        if (!save) {
            throw new CrmException(SYSTEM_ERROR.getCode(), "添加招聘计划失败");
        }

        //添加日志
        HrmRecruitReportLog hrmRecruitReportLog = new HrmRecruitReportLog();
        hrmRecruitReportLog.setPlanId(recruitPlan.getPlanId());
        hrmRecruitReportLog.setStatus(RecruitPlanStatusEnum.PENDING_REPORT.getStatus());
        hrmRecruitReportLog.setTitle(RecruitReportLogConstant.LogTitle.PLAN_NEW.getName());
        hrmRecruitReportLog.setContent(RecruitReportLogConstant.LogContent.PLAN_NEW.getName());
        hrmRecruitReportLog.setCreateTime(LocalDateTime.now());
        reportLogService.save(hrmRecruitReportLog);


        OperationLog operationLog = new OperationLog();
        operationLog.setOperationObject(recruitPlan.getPlanId(), recruitPlan.getPlanName());
        String detail = String.format("计划名称：%s，计划编号：%s，招聘年份：%s，招聘描述：%s",
                recruitPlan.getPlanName(), recruitPlan.getPlanCode(), recruitPlan.getPositionYear(),
                StrUtil.isNotEmpty(recruitPlan.getDescription()) ? recruitPlan.getDescription() : "无");
        operationLog.setOperationInfo(detail);
        operationLog.setBehavior(BehaviorEnum.SAVE);
        return operationLog;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public OperationLog setRecruitPlan(HrmRecruitPlan recruitPlan) {
        HrmRecruitPlan oldPlan = getById(recruitPlan.getPlanId());
        if (oldPlan == null) {
            throw new CrmException(SystemCodeEnum.SYSTEM_ERROR.getCode(), "招聘计划不存在");
        }

        // 记录变更内容
        StringBuilder detail = new StringBuilder();
        if (!Objects.equals(oldPlan.getPlanName(), recruitPlan.getPlanName())) {
            detail.append(String.format("计划名称：%s → %s；", oldPlan.getPlanName(), recruitPlan.getPlanName()));
        }
        if (!Objects.equals(oldPlan.getPlanCode(), recruitPlan.getPlanCode())) {
            detail.append(String.format("计划编号：%s → %s；", oldPlan.getPlanCode(), recruitPlan.getPlanCode()));
        }
        if (!Objects.equals(oldPlan.getPositionYear(), recruitPlan.getPositionYear())) {
            detail.append(String.format("招聘年份：%s → %s；", oldPlan.getPositionYear(), recruitPlan.getPositionYear()));
        }
        if (!Objects.equals(oldPlan.getDescription(), recruitPlan.getDescription())) {
            detail.append(String.format("招聘描述：%s → %s；",
                    StrUtil.isNotEmpty(oldPlan.getDescription()) ? oldPlan.getDescription() : "无",
                    StrUtil.isNotEmpty(recruitPlan.getDescription()) ? recruitPlan.getDescription() : "无"));
        }
        if (!Objects.equals(oldPlan.getStatus(), recruitPlan.getStatus())) {
            detail.append(String.format("审批状态：%s → %s；",
                    RecruitPlanStatusEnum.getNameByStatus(oldPlan.getStatus()),
                    RecruitPlanStatusEnum.getNameByStatus(recruitPlan.getStatus())));
        }

        updateById(recruitPlan);
        OperationLog operationLog = new OperationLog();
        operationLog.setOperationObject(recruitPlan.getPlanId(), recruitPlan.getPlanName());
        operationLog.setOperationInfo(detail.toString());
        operationLog.setBehavior(BehaviorEnum.UPDATE);
        return operationLog;
    }

    @Override
    public RecruitPlanVO queryById(Long planId) {
        return recruitPlanMapper.queryById(planId);
    }

    @Override
    public BasePage<RecruitPlanVO> queryRecruitPlanPageList(QueryRecruitPlanPageListBO queryRecruitPlanPageListBO) {
        BasePage<RecruitPlanVO> page = queryRecruitPlanPageListBO.parse();
        BasePage<RecruitPlanVO> recruitPlanVOBasePage = recruitPlanMapper.queryRecruitPlanPageList(page, queryRecruitPlanPageListBO);
        if (!recruitPlanVOBasePage.getList().isEmpty()) {
            // 计划上报日志
            List<HrmRecruitReportLog> logList = reportLogService.list();
            Map<Long, Long> logMap;
            if (logList != null && !logList.isEmpty()) {
                logMap = logList.stream().filter(log -> Objects.equals(log.getStatus(), RecruitPlanStatusEnum.APPROVED.getStatus()))
                        .collect(Collectors.groupingBy(HrmRecruitReportLog::getPlanId, Collectors.counting()));
            } else {
                logMap = new HashMap<>();
            }
            recruitPlanVOBasePage.getList().forEach(plan -> {
                if (logMap.containsKey(plan.getPlanId()) && logMap.get(plan.getPlanId()) >= 2) {
                    plan.setReportStatus(RecruitPlanReportStatusEnum.NO_NEED.getStatus());
                } else {
                    if (Objects.equals(RecruitPlanStatusEnum.PENDING_REPORT.getStatus(), plan.getStatus())) {
                        plan.setReportStatus(RecruitPlanReportStatusEnum.REPORT.getStatus());
                    } else if (Objects.equals(RecruitPlanStatusEnum.APPROVED.getStatus(), plan.getStatus())) {
                        plan.setReportStatus(RecruitPlanReportStatusEnum.SECONDARY_REPORT.getStatus());
                    } else if (Objects.equals(RecruitPlanStatusEnum.REJECTED.getStatus(), plan.getStatus())) {
                        plan.setReportStatus(RecruitPlanReportStatusEnum.ADJUST_REPORT.getStatus());
                    }
                }
            });
        }
        return recruitPlanVOBasePage;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public OperationLog updateRecruitPlanStatus(UpdateRecruitPlanStatusBO updateRecruitPlanStatusBO) {
        HrmRecruitPlan recruitPlan = getById(updateRecruitPlanStatusBO.getPlanId());
        if (recruitPlan == null) {
            throw new CrmException(SystemCodeEnum.SYSTEM_ERROR.getCode(), "招聘计划不存在");
        }

        Integer oldStatus = recruitPlan.getStatus();
        Integer newStatus = updateRecruitPlanStatusBO.getStatus();

        recruitPlan.setStatus(newStatus);
        updateById(recruitPlan);

        StringBuilder detail = new StringBuilder();
        detail.append(String.format("审批状态：%s → %s；",
                RecruitPlanStatusEnum.getNameByStatus(oldStatus),
                RecruitPlanStatusEnum.getNameByStatus(newStatus)));

        if (RecruitPlanStatusEnum.REJECTED.getStatus().equals(newStatus) && StrUtil.isNotEmpty(updateRecruitPlanStatusBO.getReason())) {
            detail.append(String.format("驳回原因：%s；", updateRecruitPlanStatusBO.getReason()));
        }

        OperationLog operationLog = new OperationLog();
        operationLog.setOperationObject(recruitPlan.getPlanId(), recruitPlan.getPlanName());
        operationLog.setOperationInfo(detail.toString());
        operationLog.setBehavior(BehaviorEnum.UPDATE);
        return operationLog;
    }

    @Override
    public void exportRecruitPlan(HttpServletResponse response, QueryRecruitPlanPageListBO queryRecruitPlanPageListBO) throws IOException {
        // 设置响应头
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        response.setCharacterEncoding("utf-8");
        String fileName = "招聘计划_" + DateUtil.format(new Date(), "yyyyMMddHHmmss") + ".xlsx";
        response.setHeader("Content-Disposition", "attachment; filename=" + java.net.URLEncoder.encode(fileName, "UTF-8"));

        // 直接查询所有符合条件的数据（不分页）
        List<RecruitPlanVO> dataList = recruitPlanMapper.queryAllRecruitPlanList(queryRecruitPlanPageListBO);

        // 转换为导出VO
        List<RecruitPlanExportVO> exportList = new ArrayList<>();
        for (RecruitPlanVO vo : dataList) {
            RecruitPlanExportVO exportVO = new RecruitPlanExportVO();
            BeanUtil.copyProperties(vo, exportVO);
            // 设置状态名称
            exportVO.setStatusName(RecruitPlanStatusEnum.getNameByStatus(vo.getStatus()));
            exportList.add(exportVO);
        }

        // 使用EasyExcel导出
        EasyExcel.write(response.getOutputStream(), RecruitPlanExportVO.class)
                .sheet("招聘计划")
                .doWrite(exportList);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public OperationLog deleteRecruitPlanById(Long planId) {
        if (planId == null) {
            throw new CrmException(SystemCodeEnum.SYSTEM_ERROR.getCode(), "计划ID不能为空");
        }

        // 查询要删除的计划信息
        HrmRecruitPlan plan = getById(planId);
        if (plan == null) {
            throw new CrmException(SystemCodeEnum.SYSTEM_ERROR.getCode(), "要删除的招聘计划不存在");
        }

        // 检查计划状态，只有待上报和已驳回状态的计划才能删除
        if (!RecruitPlanStatusEnum.PENDING_REPORT.getStatus().equals(plan.getStatus())
                && !RecruitPlanStatusEnum.REJECTED.getStatus().equals(plan.getStatus())) {
            throw new CrmException(SystemCodeEnum.SYSTEM_ERROR.getCode(), String.format("计划【%s】状态为【%s】，不能删除",
                    plan.getPlanName(), RecruitPlanStatusEnum.getNameByStatus(plan.getStatus())));
        }

        // 执行删除
        removeById(planId);

        // 构建操作日志
        OperationLog operationLog = new OperationLog();
        operationLog.setOperationObject(planId.toString(), "删除招聘计划");
        operationLog.setOperationInfo(String.format("计划名称：%s，计划编号：%s", plan.getPlanName(), plan.getPlanCode()));
        operationLog.setBehavior(BehaviorEnum.DELETE);

        return operationLog;
    }

    /**
     * 生成计划编号
     *
     * @return 计划编号
     */
    private String generatePlanCode(String year) {
        StringBuffer sb = new StringBuffer();
        String key = HrmCacheKey.HRM_RECRUIT_PLAN + year;
        sb.append(year);
        sb.append(String.format("%03d", redis.incr(key)));
        return sb.toString();
    }

    @Override
    public void downloadExcel(HttpServletResponse response) {
        List<JSONObject> list = queryField();
        ExcelParseUtil.importExcel(new ExcelParseUtil.ExcelParseService() {
            @Override
            public String getExcelName() {
                return "计划";
            }

            @Override
            public String getMergeContent(String module) {
                return "注意事项：\n" +
                        "1、表头标“*”的红色字体为必填项\n" +
                        "2、导入只新增不修改\n";
            }
        }, list, response, "user");
    }

    private List<JSONObject> queryField() {
        List<JSONObject> list = new ArrayList<>();
        list.add(queryField("planName", FieldEnum.TEXT.getFormType(), FieldEnum.TEXT.getType(), "计划名称", 1));
        list.add(queryField("positionYear", FieldEnum.TEXT.getFormType(), FieldEnum.TEXT.getType(), "招聘年份", 1));
        list.add(queryField("description", FieldEnum.TEXT.getFormType(), FieldEnum.TEXT.getType(), "招聘描述", 0));
        return list;
    }

    private JSONObject queryField(String fieldName, String formType, Integer type, String name, Integer isNull) {
        JSONObject json = new JSONObject();
        json.fluentPut("fieldName", fieldName)
                .fluentPut("formType", formType)
                .fluentPut("type", type)
                .fluentPut("name", name).fluentPut("isNull", isNull);
        return json;
    }

    private String getFilePath(MultipartFile file) {
        String dirPath = FileUtil.getTmpDirPath();
        try {
            InputStream inputStream = file.getInputStream();
            File fromStream = FileUtil.writeFromStream(inputStream, dirPath + "/" + IdUtil.simpleUUID() + file.getOriginalFilename());
            return fromStream.getAbsolutePath();
        } catch (IOException e) {
            throw new CrmException(SystemCodeEnum.SYSTEM_UPLOAD_FILE_ERROR);
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public JSONObject excelImport(MultipartFile file) {
        List<List<Object>> errList = new ArrayList<>();
        String filePath = getFilePath(file);
        AtomicReference<Integer> num = new AtomicReference<>(0);
        //新增部门
        List<HrmRecruitPlan> addPlanList = new ArrayList<>();

        ExcelUtil.readBySax(filePath, 0, (int sheetIndex, long rowIndex, List<Object> rowList) -> {
            if (rowIndex > 1) {
                num.getAndSet(num.get() + 1);
                if (rowList.size() < 3) {
                    int size = rowList.size();
                    for (int i = 0; i < 3 - size; i++) {
                        rowList.add("");
                    }
                }
                if (StrUtil.isEmptyIfStr(rowList.get(0).toString().trim())) {
                    rowList.add(0, "计划名称不能为空");
                    errList.add(rowList);
                    return;
                }
                if (StrUtil.isEmptyIfStr(rowList.get(1).toString().trim())) {
                    rowList.add(0, "招聘年份不能为空");
                    errList.add(rowList);
                    return;
                }

                HrmRecruitPlan plan = new HrmRecruitPlan();
                plan.setPlanName(rowList.get(0).toString().trim());
                plan.setPositionYear(rowList.get(1).toString().trim());
                plan.setDescription(rowList.get(2).toString().trim());
                plan.setPlanCode(generatePlanCode(rowList.get(1).toString().trim()));
                plan.setStatus(RecruitPlanStatusEnum.PENDING_REPORT.getStatus());
                plan.setCreateTime(LocalDateTime.now());
                addPlanList.add(plan);
            } else {
                if (rowIndex == 1) {
                    rowList.add(0, "错误信息");
                }
                errList.add(Convert.toInt(rowIndex), rowList);
            }
        });
        if (!addPlanList.isEmpty()) {
            this.saveBatch(addPlanList);
        }
        FileUtil.del(filePath);
        JSONObject result = new JSONObject().fluentPut("totalSize", num.get()).fluentPut("errSize", 0);
        int listSize = 2;
        if (errList.size() > listSize) {
            File errFile = FileUtil.file("excelData/" + IdUtil.simpleUUID() + ".xlsx");
            BigExcelWriter writer = ExcelUtil.getBigWriter(errFile);
            // 取消数据的黑色边框以及数据左对齐
            CellStyle cellStyle = writer.getCellStyle();
            cellStyle.setFillBackgroundColor(IndexedColors.BLACK.getIndex());
            cellStyle.setBorderTop(BorderStyle.NONE);
            cellStyle.setBorderBottom(BorderStyle.NONE);
            cellStyle.setBorderLeft(BorderStyle.NONE);
            cellStyle.setBorderRight(BorderStyle.NONE);
            cellStyle.setAlignment(HorizontalAlignment.LEFT);
            Font defaultFont = writer.createFont();
            defaultFont.setFontHeightInPoints((short) 11);
            cellStyle.setFont(defaultFont);
            // 取消数字格式的数据的黑色边框以及数据左对齐
            CellStyle cellStyleForNumber = writer.getStyleSet().getCellStyleForNumber();
            cellStyleForNumber.setBorderTop(BorderStyle.NONE);
            cellStyleForNumber.setBorderBottom(BorderStyle.NONE);
            cellStyleForNumber.setBorderLeft(BorderStyle.NONE);
            cellStyleForNumber.setBorderRight(BorderStyle.NONE);
            cellStyleForNumber.setAlignment(HorizontalAlignment.LEFT);
            cellStyleForNumber.setFillBackgroundColor(IndexedColors.BLACK.getIndex());
            cellStyleForNumber.setFont(defaultFont);

            CellStyle textStyle = writer.getWorkbook().createCellStyle();
            DataFormat format = writer.getWorkbook().createDataFormat();
            textStyle.setDataFormat(format.getFormat("@"));

            writer.merge(errList.get(1).size() + 1, errList.get(0).get(0).toString().trim(), true);
            writer.getHeadCellStyle().setAlignment(HorizontalAlignment.LEFT);
            writer.getHeadCellStyle().setWrapText(true);
            Font headFont = writer.createFont();
            headFont.setFontHeightInPoints((short) 11);
            writer.getHeadCellStyle().setFont(headFont);
            writer.getHeadCellStyle().setFillPattern(FillPatternType.NO_FILL);
            writer.getOrCreateRow(0).setHeightInPoints(120);
            writer.setRowHeight(-1, 20);

            //writer.merge(6, "系统用户导入模板(*)为必填项");
            for (int i = 0; i < errList.get(1).size(); i++) {
                writer.getSheet().setDefaultColumnStyle(i, textStyle);
            }
            errList.remove(0);
            writer.write(errList);
            writer.close();
            //将错误信息的excel保存七天 604800 七天的秒数
            MultipartFile multipartFile = MultipartFileUtil.getMultipartFile(errFile);
            UploadEntity uploadEntity = adminFileService.uploadTempFile(multipartFile, IdUtil.simpleUUID()).getData();

            redis.setex(AdminCacheKey.UPLOAD_EXCEL_MESSAGE_PREFIX + "file:" + uploadEntity.getFileId(), 604800, uploadEntity.getPath());

            result.fluentPut("errSize", errList.size() - 1).fluentPut("token", uploadEntity.getFileId());

        }
        return result;
    }


    @Override
    public UploadEntity uploadTempFile(MultipartFile file, String batchId) {
        Result<UploadEntity> result = adminFileService.uploadTempFile(file, batchId);
        return result.getData();
    }

    /**
     * 同步计划回调
     * @param syncDataInformationBO
     * @return
     */
    @Override
    public boolean syncPlanCallback(SyncDataInformationBO syncDataInformationBO) {
        // 解密
        String encryptData = syncDataInformationBO.getEncryptData();
        if (StrUtil.isEmpty(encryptData)) {
            throw new CrmException(SYSTEM_ERROR.getCode(), "加密数据为空");
        }
        DataForEncoder encoder = null;
        try {
            encoder = DataEncoderFactory.factory(algorithm);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        String decryptedData = encoder.dataDecryption(encryptData, secretKey);
        SyncPlanCallbackBO syncPlanCallbackBO = JSONObject.parseObject(decryptedData, SyncPlanCallbackBO.class);

        if (syncPlanCallbackBO == null) {
            throw new CrmException(SYSTEM_ERROR.getCode(), "解密数据为空");
        }
        HrmRecruitPlan plan = this.getById(Long.parseLong(syncPlanCallbackBO.getPlanId()));
        if (plan == null) {
            throw new CrmException(SYSTEM_ERROR.getCode(), "计划不存在");
        }
        if (!Objects.equals(plan.getStatus(), RecruitPlanStatusEnum.UNDER_REVIEW.getStatus())) {
            throw new CrmException(SYSTEM_ERROR.getCode(), "计划状态异常");
        }

        // 调整计划状态
        Integer status = syncPlanCallbackBO.getExamineStatus() == 1 ? RecruitPlanStatusEnum.APPROVED.getStatus() : RecruitPlanStatusEnum.REJECTED.getStatus();
        boolean b = this.lambdaUpdate().eq(HrmRecruitPlan::getPlanId, syncPlanCallbackBO.getPlanId()).set(HrmRecruitPlan::getStatus, status).update();
        if (b) {
            //添加日志
            HrmRecruitReportLog hrmRecruitReportLog = new HrmRecruitReportLog();
            hrmRecruitReportLog.setPlanId(plan.getPlanId());
            hrmRecruitReportLog.setTitle(RecruitReportLogConstant.LogTitle.PLAN_REVIEW.getName());
            if (syncPlanCallbackBO.getExamineStatus() == 1) {
                hrmRecruitReportLog.setStatus(RecruitPlanStatusEnum.APPROVED.getStatus());
                hrmRecruitReportLog.setContent(RecruitReportLogConstant.LogContent.REVIEW_PASS.getName());
            } else {
                hrmRecruitReportLog.setStatus(RecruitPlanStatusEnum.REJECTED.getStatus());
                hrmRecruitReportLog.setContent(String.format(RecruitReportLogConstant.LogContent.REVIEW_REJECT.getName(), syncPlanCallbackBO.getExamineReason()));
            }
            hrmRecruitReportLog.setCreateTime(LocalDateTime.now());
            reportLogService.save(hrmRecruitReportLog);
        }
        return b;
    }
}
